<%
# Code Review plugin for Redmine
# Copyright (C) 2010  Haruyuki Iida
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-%>
<div id="code_review_settings">
  <%
  @code_review_setting = CodeReviewProjectSetting.find_or_create(@project)

  @old_reviews = CodeReview.find(:all,
    :conditions => ['issue_id is ? and old_parent_id is ? and project_id = ?', nil, nil, @project.id])

%>

  <% labelled_tabular_form_for :setting, @code_review_setting,
    :url => {:controller => 'code_review_settings',
    :action => 'update', :id => @project, :tab => 'code_review',
    :partial => 'code_review_settings/update',
    :setting_id => @code_review_setting.id} do |f| %>
    <%= error_messages_for 'code_review_setting' %>
    <div class="box">
      <b><%=h l(:select_tracker_for_code_reviews)%>:</b>
      <p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p>

      <b><%=h l(:select_tracker_for_code_review_assignment)%>:</b>
      <p><%= f.select :assignment_tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p>

      <p>
        <%= f.check_box :hide_code_review_tab %>
      </p>

      <p>
        <label><%=h l(:label_if_revision_has_issues)%>:</label>
        <%= f.radio_button(:auto_relation, CodeReviewProjectSetting::AUTORELATION_TYPE_RELATES) %>
        <%=h l(:label_review_issue_relates) %>

        <%= f.radio_button(:auto_relation, CodeReviewProjectSetting::AUTORELATION_TYPE_BLOCKS) %>
        <%=h l(:label_review_issue_blocks) %>

        <%= f.radio_button(:auto_relation, CodeReviewProjectSetting::AUTORELATION_TYPE_NONE) %>
        <%=h l(:label_review_issue_do_nothing) %>

      </p>
      <% if @old_reviews and @old_reviews.any? %>
        <p>
          <%=h l(:old_review_data_found) %>
          <%=  radio_button_tag 'convert', true, :checked => false %><%=h l(:general_text_Yes) %>
          <%=  radio_button_tag 'convert', false, :checked => true %><%=h l(:general_text_No) %>
        </p>
      <% end %>
    </div>
    <%= submit_tag l(:button_update) %>
  <% end %>
</div>